#define _CRT_SECURE_NO_WARNINGS
#include"sort.h"


void test()
{
	FILE* mfout = fopen("test.txt", "r");
	if (!mfout)
	{
		perror("file1 open fail!");
		return ;
	}
	const char* fp1 = "file1.txt";
	const char* fp2 = "file3.txt";
	const char* mfp = "mfile.txt";
	int n = 10000;
	ReadDatasorttofile(fp1, n, mfout);
	ReadDatasorttofile(fp2, n, mfout);
	while (1)
	{
		mergefle(fp1, fp2, mfp);
		remove(fp1);
		remove(fp2);
		rename(mfp, fp1);
		int f = 0;

		if ((f=ReadDatasorttofile(fp2, n, mfout)) == 0)
		{
			break;
		}
		if (f < 100)
		{
			int x = 0;
		}
	}
}
int main()
{
	//creat();
	test();
	return 0;
}